package com.planet.processor


fun String.camelCase(): String {

    val stringBuffer = StringBuffer()

    val chars = this.toCharArray()

    var pos = 0

    var upperCase = false
    while (pos < chars.size) {
        val ch = chars[pos]
        if (ch !in '0'..'9' && ch != '_') {
            if (upperCase) {
                if (ch in 'A'..'Z') {
                    stringBuffer.append(ch.toLowerCase())
                } else {
                    stringBuffer.append(ch)
                }
                upperCase = false

            } else {
                if (ch in 'A'..'Z')
                    upperCase = true

                stringBuffer.append(ch)
            }

        }

        pos++


    }
    return stringBuffer.toString()
}